package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
//继承了tcp回显服务器就是为了复用之前的代码
public class TcpDitServer extends TcpEchoServer3{
    //1.先建立一个hash表，在构造服务器时，把对应的单词和汉译put进去
    private Map<String,String> dict = new HashMap<>();
    public TcpDitServer(int port) throws IOException {
        super(port);
        dict.put("cat","小喵~");
        dict.put("dog","小狗");
        dict.put("fuck","卧槽");
    }
    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"该单词没有查到！");
    }

    public static void main(String[] args) throws IOException {
        TcpDitServer tcpDitServer = new TcpDitServer(9009);
        tcpDitServer.start();
    }
}
